from fastapi import Body,Depends
from fastapi.encoders import jsonable_encoder

from api import app
from common.result import Result,ResultModel
from model import Session,get_session
from model.admin import AdminModel
from service.adminservice import AdminService



@app.post("/login")
async def login(admin: AdminModel = Body(...),db_session = Depends(get_session)):
    dbadmin = AdminService.login(admin,db_session)
    return Result.success(jsonable_encoder(dbadmin))